package com.xj.edu.hotel.service.serviceImpl;
import com.xj.edu.hotel.domain.User;
import com.xj.edu.hotel.mapper.UserMapper;
import com.xj.edu.hotel.service.UserService;
import io.micrometer.core.instrument.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.validation.OverridesAttribute;
import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
        return userMapper.selectAll();
    }

    @Override
    public int delectById(String id) {
        return userMapper.deleteByPrimaryKey(id);
    }



    @Override
    public int insert(User user) {
        return userMapper.insert(user);
    }

    @Override
    public int saveAllUser(User user) {
        return userMapper.insert(user);
    }

    @Override
    public User findByName(User user) {
        return userMapper.selectByName(user.getUserName());

    }
    @Override
    public User findById(String id){
        return userMapper.findById(id);
    }
    @Override
    public int editUser(User user) {
        return userMapper.updateByPrimaryKeySelective(user);
    }
}
